import Vue from 'vue'

import Element from 'element-ui'
import './assets/styles/element-variables.scss'
import Cookies from 'js-cookie'
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/base.scss' //
import App from './App'
import store from './store'
import router from './router'
import VueWait from 'vue-wait'
import './assets/icons' // icon
import './permission' // permission control

import vueHelp from '@/utils/vueHelp'
import ZhnxSSO from 'zhnx-sso'

import defaultSetting from './settings'
console.log(defaultSetting.mock)
if (defaultSetting.mock) {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// loading状态管理
Vue.use(VueWait) // add VueWait as Vue plugin
const wait = new VueWait({ registerComponents: false })
window.$wait = wait
// 构造原型对象
vueHelp.buildPrototype(Vue)
// 安装插件
vueHelp.installPlugin(Vue)
// 注册过滤器
vueHelp.buildFilter(Vue)
// 注册指令
vueHelp.buildDirective(Vue)
// 注册全局mixin
vueHelp.buildGlobalMixin(Vue)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false
// 单点登录
window.zhnxSSO = ZhnxSSO.getInstance()
const src = process.env.VUE_APP_SSO_URL
window.zhnxSSO
  .creatIframe(src)
  .then(result => console.log(result.data))
  .catch(error => console.log(error))

new Vue({
  el: '#app',
  router,
  store,
  // your vue config
  wait: wait,
  render: h => h(App)
})
